/**
 *
 * Copyright 2016-present scrm
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
import React from 'react'
import PropTypes from 'prop-types';

import {
	ListView,
	StyleSheet,
	ScrollView,
	TextInput,
	View,
	Dimensions,
	Text
} from 'react-native';

import TextInput2 from '../../components/TextInput2';
import Divider from '../../components/divider/Divider';
import colors from '../../config/colors';
import MemberCell from './MemberCell';

const propTypes = {}

class HeaderView extends React.Component {
	constructor(props, context) {
		super(props, context);
		this.state = {
			searchText: ''
		}
	};

	renderSearchBar () {
		const props = {
			secureTextEntry: false,
			underlineColorAndroid: 'transparent',
			text: this.state.searchText,
			style:styles.searchInputStyle,
			onChange: (ev) => this.props.onChange(ev),
			placeholderTextColor: colors.grey6,
			placeholderStyle: styles.placeholderStyle,
			placeholder: this.props.placeholder,
			defaultValue: this.props.defaultValue
		};
		return (
			<TextInput2
			{...props}
			 />
		)
	};

	render () {
		return (
			<View style={styles.containerStyle}>
				<View style={styles.searchWrapperStyle}>
					{this.renderSearchBar()}
				</View>
				<Divider />
				{this.props.headerContent && this.props.headerContent()}
			</View>
		)
	}
}

const styles = StyleSheet.create({
	containerStyle: {
		flex: 1,
		justifyContent: 'center',
		backgroundColor: 'white'
	},
	searchInputStyle: {
		paddingTop: 6,
		paddingBottom: 6,
		backgroundColor: colors.grey8
	},
	placeholderStyle: {
		textAlign: 'center',
		fontSize: 12,
		backgroundColor: colors.grey8
	},
	searchWrapperStyle: {
		padding: 10
	}
})

HeaderView.propTypes = propTypes;

export default HeaderView;

